package cn.iocoder.yudao.module.javainfo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum TransactionTypeEnum {
    ALIPAY(1, "ALIPAY", "支付宝"),
    WECHAT(2, "WECHAT", "微信"),
    BANK(3, "BANK", "网商银行"),
    BALANCE(4, "BALANCE", "现金"),
    SYSTEM(0, "SYSTEM", "系统默认"),
    ;

    private final Integer type;
    private final String value;
    private final String desc;

    private static Map<Integer, TransactionTypeEnum> cache;

    static {
        cache = Arrays.stream(TransactionTypeEnum.values()).collect(Collectors.toMap(TransactionTypeEnum::getType, Function.identity()));
    }

    public static TransactionTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
